package com.rentplant.controller;

import com.alibaba.fastjson.JSONObject;
import com.rentplant.Pojo.address;
import com.rentplant.service.impl.addressServiceImp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController//让它知道这是controller
@RequestMapping("/address")
public class addressController {
    @Autowired
    private addressServiceImp addressserviceimp;

    //获取地址信息
    @RequestMapping("/selectAddress")
    public List<address> selectAddress(@RequestBody JSONObject req){
        String openid = req.getString("openid");
      return addressserviceimp.addressInfo(openid);
    }

//    新增地址
    @RequestMapping("/addAddress")
    public boolean addAddress(@RequestBody JSONObject req){
        return addressserviceimp.addAddress(req);
    }


//    修改地址
    @RequestMapping("/updateAddress")
    public boolean updateAddress(@RequestBody JSONObject req)
    {
        return addressserviceimp.updateAddress(req);
    }

//    删除地址
    @RequestMapping("/delAddress")
    public boolean delAddress(@RequestBody JSONObject req){
//        System.out.println(req);
        return addressserviceimp.delAddress(req);
    }
}
